/*
 * 文件名：LanguageTypeController.java	 
 * 时     间：下午3:35:03
 * 作     者：chenyi       
 * 版     权： 2014-2022  智慧园区, 公司保留所有权利.
 * 联     系：www.szyungu.com
 */
package com.qianhai.news.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.qianhai.common.constants.CommonContans;
import com.qianhai.common.controller.BaseController;
import com.qianhai.common.exception.BaseException;
import com.qianhai.common.utils.Tools;
import com.qianhai.news.model.Languagetype;
import com.qianhai.news.model.LanguagetypeExample;
import com.qianhai.news.service.face.LanguageTypeService;

/** 
 * @ClassName: LanguageTypeController 
 * @Description: 这里用一句话描述这个类的作用 
 * @author chenyi
 * @date 2015年4月13日 下午3:35:03 
 */
@RestController
@RequestMapping(value = "/language", method = RequestMethod.POST)
public class LanguageTypeController extends BaseController
{
	@Autowired
	private LanguageTypeService languageservice;
	
	/**
	 * 
	 * @方法名称: queryList 
	 * @描述: 
	 *     查询出所有的语言分类 
	 *
	 * @参数:
	 *    @param type-status 1启用2禁用
	 *    @return
	 *
	 * @返回类型: ModelMap
	 * @作者:chenyi
	 * @可能抛出异常:
	 */
	@RequestMapping(value = "/queryList.action", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryList(@RequestBody Languagetype type)
	{
		ModelMap resultMap = new ModelMap();
		
		try
		{
			if(type == null || type.getStatus()==null){
				throw new BaseException("30000-00000-0031");
			}
			LanguagetypeExample lte = new LanguagetypeExample();
			if(type !=null && !Tools.isEmpty(type.getLcode())){
				lte.or().andStatusEqualTo(type.getStatus()).andLcodeEqualTo(type.getLcode());
			}else{
				lte.or().andStatusEqualTo(type.getStatus());
			}
			lte.setOrderByClause("sort");
			
			List<Languagetype> list = languageservice.selectByCondition(lte);
			resultMap.put(CommonContans.STRUTS_RESULT,
					CommonContans.STRUTS_SUCCESS);
			resultMap.put(CommonContans.STRUTS_DATA,list);
		} catch (Throwable e)
		{
			// 请保持所有代码一直性，没有特殊处理请使用该代码.
			this.printExction(resultMap, e);
		}
		return resultMap;
	}
}
